#include "GpuProgram.h"


namespace DreamEngine
{
CGpuProgram::CGpuProgram(ShaderProfile profile):
m_shaderProfile(profile),
m_pShaderParamTable(MATH_NULL)
{
}


CGpuProgram::~CGpuProgram(void)
{
}

Error CGpuProgram::Initialize(const CString& fileName, const CString& enterFun)
{
	CheckEngineError(LoadFromFile(fileName, enterFun));
	CheckEngineError(CreateShader());
	CheckEngineError(CreateParamTable());

	return ERROR_OK;
}

void CGpuProgram::Destory()
{
	if (m_pShaderParamTable != MATH_NULL)
		m_pShaderParamTable->Destory();
}

void CGpuProgram::Update()
{
	UpdateAutoParams();
	UpdateParams();
}

ShaderType CGpuProgram::GetType()const
{
	switch (m_shaderProfile)
	{
	case SP_PS_2_0:
	case SP_PS_3_0:
		return ST_FRAGMENT;

	case SP_VS_2_0:
	case SP_VS_3_0:
		return ST_VERTEX;

	default:
		return ST_UNKOWN;
	}
}



//CFragmentProgram::CFragmentProgram(ShaderProfile profile):
//CGpuProgram(profile)
//{
//}
//CFragmentProgram::~CFragmentProgram(void)
//{
//
//}
//
//CVertexProgram::CVertexProgram(ShaderProfile profile):
//CGpuProgram(profile)
//{
//
//}
//
//CVertexProgram::~CVertexProgram(void)
//{
//}

}

